<template>
  <div>
    <div class="header">
      <div class="logo">
        <img src="@/utils/img/titleView.png" alt="">
      </div>
      <div class="search">
        <van-search
          shape="round"
          background="white"
          placeholder="搜索我的尖叫好物"
        />
      </div>
    </div>
    <div class="head-nav">
      <ul class="nav">
        <li v-for="(data,index) in headnav" :key="index" :class="nowTitle===data.component?'navtab':''" @click="handleIndex(data.component)">{{data.title}}
        </li>
      </ul>
    </div>
    <div>
      <div :is="nowTitle"></div>
    </div>
  </div>
</template>

<script>
import recommend from './index/recommend'
import space from './index/space'
import stayhome from './index/stayhome'
import Vue from 'vue'
import { Search } from 'vant'

Vue.use(Search)
export default {
  data () {
    return {
      nowTitle: 'recommend',
      headnav: [
        { title: '推荐', component: 'recommend' },
        { title: '品质空间', component: 'space' },
        { title: '居家好物', component: 'stayhome' }
      ]
    }
  },
  methods: {
    handleIndex (component) {
      this.nowTitle = component
    }
  },
  components: {
    stayhome,
    space,
    recommend
  }
}
</script>

<style lang="scss" scoped>
.header{
  display: flex;
  width: 100%;
  height: 45px;
  align-items: center;
  background:white;
  padding-top: 5px;
  box-sizing: border-box;
  .logo{
    width: 100px;
    text-align: center;
    img{
      width: 72px;
    }
  }
  .search{
    width: calc(100% - 100px);
    height: 45px;
    .van-search {
      padding: 3px 12px;
    }
  }
}
.head-nav{
  width: 100%;
  height: 46px;
  background: white;
  .nav{
    display: flex;
    font-size: 14px;
    justify-content: space-evenly;
    align-items: center;
    height: 47px;
    li{
      width: 22%;
      overflow: hidden;
      text-align: center;
      color: rgb(138, 138, 138);
      height:47px;
      display:flex;
      align-items: center;
      justify-content:center;
    }
  }
}
.navtab{
  border-bottom: 3px solid black;
  color:black!important;
}
</style>
